package com.cloud.dataway.controller;


import com.cloud.dataway.entity.UserEntity;
import com.cloud.dataway.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yazhou
 * @since 2020-04-25
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/{id}")
    public UserEntity get(@PathVariable("id") Integer id){
        return userService.getById(id);
    }

    @GetMapping("/getSlave")
    public List<UserEntity> getSlave(){
        return userService.getSlave();
    }

    @PutMapping()
    public boolean add(@RequestBody UserEntity userEntity){
        return userService.save(userEntity);
    }

    @PostMapping()
    public boolean update(@RequestBody UserEntity userEntity){
         return userService.update(userEntity);
    }
}

